import logging

from django.shortcuts import render

from blog.models import Article

# Create your views here.

logger = logging.getLogger(__name__)


def index(request):
    """
    首页
    :param request:
    :return:
    """
    logger.info("进入首页")
    article_list = Article.objects.all().order_by("-update_time")
    return render(request, "index.html", locals())


def blog_list(request):
    """
    博客列表
    :param request:
    :return:
    """
    logger.info("博客列表")
    for i in request.session.items():
        logger.info(i)
    return render(request, "index.html", locals())


def article_detail(request, article_uid):
    """
    文章内容
    :param request:
    :param article_uid:
    :return:
    """
    logger.info("进入文章内容")
    logger.info("文章ID:article_uid=[%s]", article_uid)
    article = Article.objects.get(uid=article_uid)
    logger.info(article)
    logger.info(article.content)
    return render(request, "blog/article_index.html", locals())
